package com.framework.yhbapi.controller;

import com.framework.exception.util.RespResult;
import com.framework.service.yhbservice.YhbGoodsService;
import com.framework.yhbEntity.ter.YhbGoodsInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 功能描述: 终端信息控制器
 *
 * @author ck
 * @date 2018/9/11 15:12
 */
@RestController
@Api(value="商品列表",tags={"商品列表"})
@RequestMapping(value = "yhbGoods")
public class YhbGoodsController {

	@Autowired
	private YhbGoodsService yhbGoodsService;


	/**
	 * 查询商户的sn信息列表
	 * @param deptId
	 * @return
	 */
	@PostMapping("queryGoodsList")
	@ApiOperation("查询商品列表")
	@ApiImplicitParams({
			@ApiImplicitParam(name="deptId",value="渠道id",dataType="String", paramType = "query",required = true),
			@ApiImplicitParam(name="goodsType",value="商品类型 0：全部  1：机具  2：物料",dataType="Integer", paramType = "query",required = true),
	})
	public RespResult queryTerminalInfoList(Long deptId,Integer goodsType){
		List<YhbGoodsInfo> list = yhbGoodsService.queryGoodsList(deptId,goodsType);
		return RespResult.ok().put("list",list);
	}

	/**
	 * 根据id查询机具物料详情
	 * @param goodsId 机具物料id
	 * @return
	 */
	@GetMapping("queryGoodsInfo")
	@ApiOperation("根据id查询机具物料详情")
	@ApiImplicitParams({
			@ApiImplicitParam(name="goodsId",value="商品Id",dataType="Long", paramType = "query" ,required = true),
	})
	public RespResult queryGoodsInfo(Long deptId,Long goodsId) {
		Map<String,Object> map = yhbGoodsService.queryGoodsInfo(deptId,goodsId);
		return RespResult.ok(map);
	}

}
